/**
 * Created by 陈思兵 on 2018/4/2.
 */
import java.io.*;
import java.util.Scanner;
public class exp1 {
    public static void main(String[] args) {
          Encrypy p1 = new Encrypy();
          Decrypt p2 = new Decrypt();
          Scanner in = new Scanner(System.in);
          System.out.print("请选择操作（1.加密 2.解密）:");
          int n = in.nextInt();
          if(n == 1) {       //进行加密
              System.out.println("请输入明文：");
              String mingwen = in.next();
              System.out.println("请输入密钥：");
              int miyao = in.nextInt();
              try {
                  String secret = p1.encrpy(mingwen,miyao);
                  System.out.println("密文是："+secret);
              }
              catch(exp1Exception e) {
                  System.out.println(e.warnMess());
              }
          }
          else if(n == 2) {    //进行解密
              System.out.println("请输入密文：");
              String miwen = in.next();
              System.out.println("请输入密钥：");
              int miyao = in.nextInt();
              try {
                  String secret = p2.decrypt(miwen,miyao);
                  System.out.println("明文是："+secret);
              }
              catch(exp1Exception e) {
                  System.out.println(e.warnMess());
              }
          }
          else {    //异常
              System.out.println("请正确选择");
          }
    }
}
